package reduce.fz.com.reduce.util.http;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;

import java.util.HashMap;
import java.util.Map;

import reduce.fz.com.reduce.bean.User;
import reduce.fz.com.reduce.service.preference.UserPreference;

/**
 * Created by qingshengzheng on 15/7/12.
 */
public class ReduceRequest extends StringRequest implements ChangeDomainPolicy {
    private FeelRetryPolicy mFeelRetryPolicy;

    private static String request_domain = null;
    private static int change = 0;

    static {
        request_domain = "";
    }

    private final static String HTTP_PREFIX = "http://";
    private final static String HTTPS_PREFIX = "https://";

    public ReduceRequest(String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        super(url, listener, errorListener);
        mFeelRetryPolicy = new FeelRetryPolicy(this);
        setRetryPolicy(mFeelRetryPolicy);

    }

    public ReduceRequest(int method, String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        super(method, url, listener, errorListener);
        mFeelRetryPolicy = new FeelRetryPolicy(this);
        setRetryPolicy(mFeelRetryPolicy);

    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> _headers = new HashMap<String, String>();
        User user = UserPreference.getUser();
        if (user != null) {
            _headers.put("uid", user.uid + "");
            _headers.put("mobile", user.mobile);
        }
        return _headers;
    }

    @Override
    public void changeDomainIP() {
    }
}